*===============================================================================*
*																				*
*		THIS DO FILE PRODUCES ONLINE APPENDIX TABLE A2							*
* 		IN LONDONO-VELEZ AND QUERUBIN											*
*		"THE IMPACT OF EMERGENCY CASH ASSISTANCE IN A PANDEMIC: EXPERIMENTAL 	* 
* 		EVIDENCE FROM COLOMBIA", REVIEW OF ECONOMICS AND STATISTICS				*
*																				*
*		LAST MODIFIED: 2021-02-02												*
*																				*
*===============================================================================*

	use 	"${datadir}/balance.dta", clear
	
	gen 	N = 1
	label 	var N "N"
	global 	controls "treated cm MPM cod_urban sisben4 sisben3 Female age_01apr2020 estadocivil_1 estadocivil_2 estadocivil_3 estadocivil_4 estadocivil_5 victim"
	
	glo 	rows = 16
	matrix 	results = J($rows,4,.)
	matrix 	rown results = $controls
	
	local tt = 0
	foreach t of numlist 0 1{
	local oo = 0
	foreach o in $controls{	
		local l`o' : variable label `o'
				if `"`l`o''"' == "" {
					local l`o' "`o'"
					}
	qui: sum `o' if Complete == `t'
	matrix results[1+`oo',`tt'+1]=round(r(mean), .001)
	qui: reg `o' Complete, r 
	matrix results[1+`oo',3]=round((2 * ttail(e(df_r), abs(_b[Complete]/_se[Complete]))), .001)
	qui: reghdfe `o' Complete, abs(codmunicipio) vce(robust)	
	matrix results[1+`oo',4]=round((2 * ttail(e(df_r), abs(_b[Complete]/_se[Complete]))), .001)
	local oo = `oo'+1
	}
	qui: sum N if Complete == `t'
	matrix results[$rows,`tt'+1]=r(N)	
	local tt = `tt'+1
	}
	matrix list results
	svmat results
	keep results*
	drop if _n>$rows
	rename results1 NotComplete
	rename results2	Complete
	rename results3 pvalue
	rename results4 MunFE_pvalue
	gen 	variable = ""
	local oo = 1
	foreach o in $controls{	
	replace variable = "`l`o''" in `oo'
	local oo = `oo'+1
	}
	order 	variable NotComplete Complete pvalue
	format  NotComplete Complete pvalue MunFE_pvalue %5.3f
	export 	excel using "OnlineAppendix/TA2", sheet("TA2") sheetreplace firstrow(variables)
	
